﻿using AutoMapper;
using StarsAdmin.Application.Role.Dtos;
using StarsAdmin.Core.DB.Entities;
using StarsAdmin.Core.Models;

namespace StarsAdmin.Application.Role.Mappings
{
    public class RoleAutoMapperProFile : Profile
    {
        public RoleAutoMapperProFile()
        {
            CreateMap<Page<RoleEntity>, Page<RoleDto>>();
            CreateMap<AddRoleInput, RoleEntity>();
            CreateMap<UpdateRoleInput, RoleEntity>();
            CreateMap<RoleEntity, RoleDto>()
                .ForMember(dest => dest.MenuIds, opt => opt.MapFrom(src => src.Menus.Select(e => e.Id)));
            CreateMap<RoleEntity, ExportRoleDto>();
        }
    }
}